package net.crowdloud.client.crowdLoud;

import java.util.List;

import net.crowdloud.client.GlobalVariables;
import net.crowdloud.client.tags.TagsList;
import net.crowdloud.shared.engine.CrowdLoudGroupsEngine;
import net.crowdloud.shared.engine.CrowdLoudTagsEngine;
import net.crowdloud.shared.entities.User;
import net.crowdloud.shared.utilities.HomeIcon;

import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.VerticalPanel;

/**
 * 
 * @Feature
 */
public class AllCrowdLoudPage extends VerticalPanel {

	public AllCrowdLoudPage(String group) {

		VerticalPanel vp = new VerticalPanel();
		vp.setSize("97%", "100%");

		vp.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
		HorizontalPanel hp = new HorizontalPanel();
		hp.setSpacing(5);

		hp.setWidth("300px");
		hp.add(new HomeIcon());
		vp.add(hp);
		vp.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);

		VerticalPanel vp1 = new VerticalPanel();
		vp1.setSize("100%", "100%");
		vp1.setSpacing(10);

		vp1.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
		HTML html = new HTML("<br><br><br><b><font color='blue' size='3'>"
				+ (group != null ? group : "") + " CROWD LOUD</font></b> ");
		vp1.add(html);

		List<User> usersGroup;
		if (group != null) {

			usersGroup = CrowdLoudGroupsEngine.getUsersGroup(
					GlobalVariables.users, group);
		} else {

			usersGroup = GlobalVariables.users;
		}

		vp1.add(new TagsList(CrowdLoudTagsEngine.getTagsList(usersGroup,
				GlobalVariables.tags.getTagsList())));

		vp.add(vp1);

		this.add(vp);

	}
}
